<template>
  <div class="app-container">
    <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" :filters="filters" />
  </div>
</template>
<script>
  import WiseCrud from '@/components/Crud/wiseCrud'
  export default {
    name: 'UserCountInfo',
    components: {
      WiseCrud
    },
    data() {
      return {
        urls: {
          list: '/api/v1/welder-sbtx-second/user-count-info-comb/list',
          add: '/api/v1/welder-sbtx-second/user-count-info/create',
          show: '/api/v1/welder-sbtx-second/user-count-info/show/',
          update: '/api/v1/welder-sbtx-second/user-count-info/update/',
          delete: '/api/v1/welder-sbtx-second/user-count-info/remove/'
        }
      }
    },
    computed: {
      spaceId() {
        return this.$store.state.project.spaceId
      },
      handle() {
        return ['add']
      },
      fields() {
        let arr = [{
          label: '序号',
          type: 'index',
          use: ['table']
        }]
        if (this.$store.state.user.project) {
          arr.push({
            prop: 'projectId',
            defaultValue: this.$store.state.user.project.id,
            use: ['add', 'edit']
          })
        } else {
          // arr.push({
          //   label: '所属项目',
          //   prop: 'projectInfo',
          //   type: 'select',
          //   labelWidth: '130px',
          //   url: '/api/v1/welder-sbtx-second/project-info',
          //   labelKey: 'name',
          //   valueKey: 'id',
          //   objKeys: [
          //     {
          //       field: 'projectId',
          //       key: 'id'
          //     }
          //   ],
          //   rules: [
          //     { required: true, message: '请选择项目', trigger: 'change' }
          //   ],
          //   placeholder: '请选择项目',
          //   use: ['add', 'edit', 'filters']
          // })
          // arr.push({
          //   label: '所属项目',
          //   prop: 'manage',
          //   type: 'render',
          //   labelWidth: '130px',
          //   tableRender: (h, row, index) => {
          //     return h('div', row.projectInfo ? row.projectInfo.name : '')
          //   },
          //   viewRender: (h, item, object) => {
          //     return h('div', object.projectInfo ? object.projectInfo.name : '')
          //   },
          //   use: ['table', 'view']
          // })
        }
        arr.push({
          label: '人员类型名称',
          prop: 'userTypeName',
          type: 'text',
          labelWidth: '130px',
          rules: [{
            required: true,
            message: '请输入人员类型名称',
            trigger: 'change'
          }],
          placeholder: '请输入人员类型名称',
          use: ['table', 'add', 'view', 'edit', 'search']
        }, {
          label: '人员类型人数',
          prop: 'userTypeCount',
          type: 'number',
          labelWidth: '130px',
          rules: [{
            required: true,
            message: '请输入人员类型人数',
            trigger: 'change'
          }],
          placeholder: '请输入人员类型人数',
          use: ['table', 'add', 'view', 'edit', 'search']
        }, {
          prop: 'spaceId',
          defaultValue: this.$store.state.project.spaceId,
          use: ['add', 'edit']
        })
        arr.push({
          label: '操作',
          type: 'handle',
          use: ['table'],
          handle: ['edit', 'view', 'delete'],
          tableWidth: 300
        })
        return arr
      },

      filters() {
        return [{
          field: 'spaceId',
          operator: 'EQUALS',
          value: this.$store.state.project.spaceId
        }]
      }
    },
    methods: {}
  }
</script>

<style>
</style>